const { orderInfo } = require("../../utils/api");

// pages/logisticsinfo/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderId: '',
    orderDetail: {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

    this.setData({
      orderId: options.orderid
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getOrder()
  },

  async getOrder() {
    let params = {
      orderid: this.data.orderId
    }
    await orderInfo(params).then((res) => {

      if (res.errcode == 0) {
        this.setData({
          orderDetail: res.data.order
        })
      } else {
        wx.showToast({
          title: res.errmsg,
          icon: 'none',
        });

      }
    })
  },

  toCopy() {
    let that = this
    wx.setClipboardData({
      data: that.data.orderDetail.logisticno,
      success: function (res) {
        wx.showToast({
          title: '复制成功',
          icon: 'success',
          duration: 2000
        })
      },
      fail(err) {

      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },
  onBack() {
    wx.navigateBack({
      delta: 1
    })
  },



})